﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class View_IMG_IMG001_1 : ViewMatrix
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Title = "匯損與避險查詢";
        criteriaList = new string[] { "Criteria", "twym" };
        serviceName = "MISAPP.Classify.Service.Service_IMG001";
        if (!IsPostBack)
        {
            getData();
        }   
    }

    protected void CLB_Summary_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string v1,v2;
            v1 = e.Row.Cells[e.Row.Cells.Count - 1].Text;
            v2 = e.Row.Cells[e.Row.Cells.Count - 2].Text;
            if (!v1.Equals(v2))
            {
                e.Row.CssClass = "diff";
            }
            
        }
    }

    protected void getData()
    {
        //item
        string groupByList = string.Format("{0},","item");
        System.Data.DataTable dt = GetDataFromSerevice("GetSummaryData");
        string[] lst = groupByList.Split(new Char[] { ',' }
            ,StringSplitOptions.RemoveEmptyEntries);
        CLB_Summary.SetData(dt, lst);
    }

    protected void previous_click(object sender, EventArgs e)
    {
        Utility.SessionClear();
    }

    protected void CLB_Summary_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("detail"))
        {
            serviceName = "MISAPP.Classify.Service.Service_IMG001";
            criteriaList = new string[] { "key" };

            Session["key"] = CLB_Summary.SelectKeyValue;

            FillToSession();
            string strPage, pageParameter;
            pageParameter = "method=GetDetailData&xls=IMG001_Detail&service=Service_IMG001";
            strPage = string.Format("../GV2XLS.aspx?{0}", pageParameter);

            Server.Transfer(strPage);

        }
    }

    protected void btn2Excel_Click(object sender, EventArgs e)
    {
        //serviceName = "MISAPP.Classify.Service.Service_WMG005";
        //criteriaList = new string[] { "Criteria" };

        FillToSession();

        string pageParameter;
        pageParameter = string.Format(
             "method=GetSummaryData&xls=IMG001&service=Service_IMG001&caption={0}&captionRight={1}&toHtmlMethod={2}"
             ,this.Title, string.Empty, string.Empty);



        btn2Excel.PreviousPage = "../GV2XLS.aspx";
        btn2Excel.PageParameter = pageParameter;
    }
}
